home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / info / lispref.info-40.z / lispref.info-40
Encoding:
GNU Info File  |  1998-05-21  |  46.2 KB  |  1,064 lines

  1. This is Info file ../../info/lispref.info, produced by Makeinfo version
  2. 1.68 from the input file lispref.texi.
  3.  
  4.    Edition History:
  5.  
  6.    GNU Emacs Lisp Reference Manual Second Edition (v2.01), May 1993 GNU
  7. Emacs Lisp Reference Manual Further Revised (v2.02), August 1993 Lucid
  8. Emacs Lisp Reference Manual (for 19.10) First Edition, March 1994
  9. XEmacs Lisp Programmer's Manual (for 19.12) Second Edition, April 1995
  10. GNU Emacs Lisp Reference Manual v2.4, June 1995 XEmacs Lisp
  11. Programmer's Manual (for 19.13) Third Edition, July 1995 XEmacs Lisp
  12. Reference Manual (for 19.14 and 20.0) v3.1, March 1996 XEmacs Lisp
  13. Reference Manual (for 19.15 and 20.1, 20.2) v3.2, April, May 1997
  14.  
  15.    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software
  16. Foundation, Inc.  Copyright (C) 1994, 1995 Sun Microsystems, Inc.
  17. Copyright (C) 1995, 1996 Ben Wing.
  18.  
  19.    Permission is granted to make and distribute verbatim copies of this
  20. manual provided the copyright notice and this permission notice are
  21. preserved on all copies.
  22.  
  23.    Permission is granted to copy and distribute modified versions of
  24. this manual under the conditions for verbatim copying, provided that the
  25. entire resulting derived work is distributed under the terms of a
  26. permission notice identical to this one.
  27.  
  28.    Permission is granted to copy and distribute translations of this
  29. manual into another language, under the above conditions for modified
  30. versions, except that this permission notice may be stated in a
  31. translation approved by the Foundation.
  32.  
  33.    Permission is granted to copy and distribute modified versions of
  34. this manual under the conditions for verbatim copying, provided also
  35. that the section entitled "GNU General Public License" is included
  36. exactly as in the original, and provided that the entire resulting
  37. derived work is distributed under the terms of a permission notice
  38. identical to this one.
  39.  
  40.    Permission is granted to copy and distribute translations of this
  41. manual into another language, under the above conditions for modified
  42. versions, except that the section entitled "GNU General Public License"
  43. may be included in a translation approved by the Free Software
  44. Foundation instead of in the original English.
  45.  
  46. 
  47. File: lispref.info,  Node: Basic Coding System Functions,  Next: Coding System Property Functions,  Prev: Coding System Properties,  Up: Coding Systems
  48.  
  49. Basic Coding System Functions
  50. -----------------------------
  51.  
  52.  - Function: find-coding-system CODING-SYSTEM-OR-NAME
  53.      This function retrieves the coding system of the given name.
  54.  
  55.      If CODING-SYSTEM-OR-NAME is a coding-system object, it is simply
  56.      returned.  Otherwise, CODING-SYSTEM-OR-NAME should be a symbol.
  57.      If there is no such coding system, `nil' is returned.  Otherwise
  58.      the associated coding system object is returned.
  59.  
  60.  - Function: get-coding-system NAME
  61.      This function retrieves the coding system of the given name.  Same
  62.      as `find-coding-system' except an error is signalled if there is no
  63.      such coding system instead of returning `nil'.
  64.  
  65.  - Function: coding-system-list
  66.      This function returns a list of the names of all defined coding
  67.      systems.
  68.  
  69.  - Function: coding-system-name CODING-SYSTEM
  70.      This function returns the name of the given coding system.
  71.  
  72.  - Function: make-coding-system NAME TYPE &optional DOC-STRING PROPS
  73.      This function registers symbol NAME as a coding system.
  74.  
  75.      TYPE describes the conversion method used and should be one of the
  76.      types listed in *Note Coding System Types::.
  77.  
  78.      DOC-STRING is a string describing the coding system.
  79.  
  80.      PROPS is a property list, describing the specific nature of the
  81.      character set.  Recognized properties are as in *Note Coding
  82.      System Properties::.
  83.  
  84.  - Function: copy-coding-system OLD-CODING-SYSTEM NEW-NAME
  85.      This function copies OLD-CODING-SYSTEM to NEW-NAME.  If NEW-NAME
  86.      does not name an existing coding system, a new one will be created.
  87.  
  88.  - Function: subsidiary-coding-system CODING-SYSTEM EOL-TYPE
  89.      This function returns the subsidiary coding system of
  90.      CODING-SYSTEM with eol type EOL-TYPE.
  91.  
  92. 
  93. File: lispref.info,  Node: Coding System Property Functions,  Next: Encoding and Decoding Text,  Prev: Basic Coding System Functions,  Up: Coding Systems
  94.  
  95. Coding System Property Functions
  96. --------------------------------
  97.  
  98.  - Function: coding-system-doc-string CODING-SYSTEM
  99.      This function returns the doc string for CODING-SYSTEM.
  100.  
  101.  - Function: coding-system-type CODING-SYSTEM
  102.      This function returns the type of CODING-SYSTEM.
  103.  
  104.  - Function: coding-system-property CODING-SYSTEM PROP
  105.      This function returns the PROP property of CODING-SYSTEM.
  106.  
  107. 
  108. File: lispref.info,  Node: Encoding and Decoding Text,  Next: Detection of Textual Encoding,  Prev: Coding System Property Functions,  Up: Coding Systems
  109.  
  110. Encoding and Decoding Text
  111. --------------------------
  112.  
  113.  - Function: decode-coding-region START END CODING-SYSTEM &optional
  114.           BUFFER
  115.      This function decodes the text between START and END which is
  116.      encoded in CODING-SYSTEM.  This is useful if you've read in
  117.      encoded text from a file without decoding it (e.g. you read in a
  118.      JIS-formatted file but used the `binary' or `no-conversion' coding
  119.      system, so that it shows up as `^[$B!<!+^[(B').  The length of the
  120.      encoded text is returned.  BUFFER defaults to the current buffer
  121.      if unspecified.
  122.  
  123.  - Function: encode-coding-region START END CODING-SYSTEM &optional
  124.           BUFFER
  125.      This function encodes the text between START and END using
  126.      CODING-SYSTEM.  This will, for example, convert Japanese
  127.      characters into stuff such as `^[$B!<!+^[(B' if you use the JIS
  128.      encoding.  The length of the encoded text is returned.  BUFFER
  129.      defaults to the current buffer if unspecified.
  130.  
  131. 
  132. File: lispref.info,  Node: Detection of Textual Encoding,  Next: Big5 and Shift-JIS Functions,  Prev: Encoding and Decoding Text,  Up: Coding Systems
  133.  
  134. Detection of Textual Encoding
  135. -----------------------------
  136.  
  137.  - Function: coding-category-list
  138.      This function returns a list of all recognized coding categories.
  139.  
  140.  - Function: set-coding-priority-list LIST
  141.      This function changes the priority order of the coding categories.
  142.      LIST should be a list of coding categories, in descending order of
  143.      priority.  Unspecified coding categories will be lower in priority
  144.      than all specified ones, in the same relative order they were in
  145.      previously.
  146.  
  147.  - Function: coding-priority-list
  148.      This function returns a list of coding categories in descending
  149.      order of priority.
  150.  
  151.  - Function: set-coding-category-system CODING-CATEGORY CODING-SYSTEM
  152.      This function changes the coding system associated with a coding
  153.      category.
  154.  
  155.  - Function: coding-category-system CODING-CATEGORY
  156.      This function returns the coding system associated with a coding
  157.      category.
  158.  
  159.  - Function: detect-coding-region START END &optional BUFFER
  160.      This function detects coding system of the text in the region
  161.      between START and END.  Returned value is a list of possible coding
  162.      systems ordered by priority.  If only ASCII characters are found,
  163.      it returns `autodetect' or one of its subsidiary coding systems
  164.      according to a detected end-of-line type.  Optional arg BUFFER
  165.      defaults to the current buffer.
  166.  
  167. 
  168. File: lispref.info,  Node: Big5 and Shift-JIS Functions,  Prev: Detection of Textual Encoding,  Up: Coding Systems
  169.  
  170. Big5 and Shift-JIS Functions
  171. ----------------------------
  172.  
  173.    These are special functions for working with the non-standard
  174. Shift-JIS and Big5 encodings.
  175.  
  176.  - Function: decode-shift-jis-char CODE
  177.      This function decodes a JISX0208 character of Shift-JIS
  178.      coding-system.  CODE is the character code in Shift-JIS as a cons
  179.      of type bytes.  The corresponding character is returned.
  180.  
  181.  - Function: encode-shift-jis-char CH
  182.      This function encodes a JISX0208 character CH to SHIFT-JIS
  183.      coding-system.  The corresponding character code in SHIFT-JIS is
  184.      returned as a cons of two bytes.
  185.  
  186.  - Function: decode-big5-char CODE
  187.      This function decodes a Big5 character CODE of BIG5 coding-system.
  188.      CODE is the character code in BIG5.  The corresponding character
  189.      is returned.
  190.  
  191.  - Function: encode-big5-char CH
  192.      This function encodes the Big5 character CHAR to BIG5
  193.      coding-system.  The corresponding character code in Big5 is
  194.      returned.
  195.  
  196. 
  197. File: lispref.info,  Node: CCL,  Next: Category Tables,  Prev: Coding Systems,  Up: MULE
  198.  
  199. CCL
  200. ===
  201.  
  202.  - Function: execute-ccl-program CCL-PROGRAM STATUS
  203.      This function executes CCL-PROGRAM with registers initialized by
  204.      STATUS.  CCL-PROGRAM is a vector of compiled CCL code created by
  205.      `ccl-compile'.  STATUS must be a vector of nine values, specifying
  206.      the initial value for the R0, R1 .. R7 registers and for the
  207.      instruction counter IC.  A `nil' value for a register initializer
  208.      causes the register to be set to 0.  A `nil' value for the IC
  209.      initializer causes execution to start at the beginning of the
  210.      program.  When the program is done, STATUS is modified (by
  211.      side-effect) to contain the ending values for the corresponding
  212.      registers and IC.
  213.  
  214.  - Function: execute-ccl-program-string CCL-PROGRAM STATUS STR
  215.      This function executes CCL-PROGRAM with initial STATUS on STRING.
  216.      CCL-PROGRAM is a vector of compiled CCL code created by
  217.      `ccl-compile'.  STATUS must be a vector of nine values, specifying
  218.      the initial value for the R0, R1 .. R7 registers and for the
  219.      instruction counter IC.  A `nil' value for a register initializer
  220.      causes the register to be set to 0.  A `nil' value for the IC
  221.      initializer causes execution to start at the beginning of the
  222.      program.  When the program is done, STATUS is modified (by
  223.      side-effect) to contain the ending values for the corresponding
  224.      registers and IC.  Returns the resulting string.
  225.  
  226.  - Function: ccl-reset-elapsed-time
  227.      This function resets the internal value which holds the time
  228.      elapsed by CCL interpreter.
  229.  
  230.  - Function: ccl-elapsed-time
  231.      This function returns the time elapsed by CCL interpreter as cons
  232.      of user and system time.  This measures processor time, not real
  233.      time.  Both values are floating point numbers measured in seconds.
  234.      If only one overall value can be determined, the return value
  235.      will be a cons of that value and 0.
  236.  
  237. 
  238. File: lispref.info,  Node: Category Tables,  Prev: CCL,  Up: MULE
  239.  
  240. Category Tables
  241. ===============
  242.  
  243.    A category table is a type of char table used for keeping track of
  244. categories.  Categories are used for classifying characters for use in
  245. regexps - you can refer to a category rather than having to use a
  246. complicated [] expression (and category lookups are significantly
  247. faster).
  248.  
  249.    There are 95 different categories available, one for each printable
  250. character (including space) in the ASCII charset.  Each category is
  251. designated by one such character, called a "category designator".  They
  252. are specified in a regexp using the syntax `\cX', where X is a category
  253. designator. (This is not yet implemented.)
  254.  
  255.    A category table specifies, for each character, the categories that
  256. the character is in.  Note that a character can be in more than one
  257. category.  More specifically, a category table maps from a character to
  258. either the value `nil' (meaning the character is in no categories) or a
  259. 95-element bit vector, specifying for each of the 95 categories whether
  260. the character is in that category.
  261.  
  262.    Special Lisp functions are provided that abstract this, so you do not
  263. have to directly manipulate bit vectors.
  264.  
  265.  - Function: category-table-p OBJ
  266.      This function returns `t' if ARG is a category table.
  267.  
  268.  - Function: category-table &optional BUFFER
  269.      This function returns the current category table.  This is the one
  270.      specified by the current buffer, or by BUFFER if it is non-`nil'.
  271.  
  272.  - Function: standard-category-table
  273.      This function returns the standard category table.  This is the
  274.      one used for new buffers.
  275.  
  276.  - Function: copy-category-table &optional TABLE
  277.      This function constructs a new category table and return it.  It
  278.      is a copy of the TABLE, which defaults to the standard category
  279.      table.
  280.  
  281.  - Function: set-category-table TABLE &optional BUFFER
  282.      This function selects a new category table for BUFFER.  One
  283.      argument, a category table.  BUFFER defaults to the current buffer
  284.      if omitted.
  285.  
  286.  - Function: category-designator-p OBJ
  287.      This function returns `t' if ARG is a category designator (a char
  288.      in the range `' '' to `'~'').
  289.  
  290.  - Function: category-table-value-p OBJ
  291.      This function returns `t' if ARG is a category table value.  Valid
  292.      values are `nil' or a bit vector of size 95.
  293.  
  294. 
  295. File: lispref.info,  Node: Tips,  Next: Building XEmacs and Object Allocation,  Prev: MULE,  Up: Top
  296.  
  297. Tips and Standards
  298. ******************
  299.  
  300.    This chapter describes no additional features of XEmacs Lisp.
  301. Instead it gives advice on making effective use of the features
  302. described in the previous chapters.
  303.  
  304. * Menu:
  305.  
  306. * Style Tips::                Writing clean and robust programs.
  307. * Compilation Tips::          Making compiled code run fast.
  308. * Documentation Tips::        Writing readable documentation strings.
  309. * Comment Tips::          Conventions for writing comments.
  310. * Library Headers::           Standard headers for library packages.
  311.  
  312. 
  313. File: lispref.info,  Node: Style Tips,  Next: Compilation Tips,  Up: Tips
  314.  
  315. Writing Clean Lisp Programs
  316. ===========================
  317.  
  318.    Here are some tips for avoiding common errors in writing Lisp code
  319. intended for widespread use:
  320.  
  321.    * Since all global variables share the same name space, and all
  322.      functions share another name space, you should choose a short word
  323.      to distinguish your program from other Lisp programs.  Then take
  324.      care to begin the names of all global variables, constants, and
  325.      functions with the chosen prefix.  This helps avoid name conflicts.
  326.  
  327.      This recommendation applies even to names for traditional Lisp
  328.      primitives that are not primitives in XEmacs Lisp--even to `cadr'.
  329.      Believe it or not, there is more than one plausible way to define
  330.      `cadr'.  Play it safe; append your name prefix to produce a name
  331.      like `foo-cadr' or `mylib-cadr' instead.
  332.  
  333.      If you write a function that you think ought to be added to Emacs
  334.      under a certain name, such as `twiddle-files', don't call it by
  335.      that name in your program.  Call it `mylib-twiddle-files' in your
  336.      program, and send mail to `bug-gnu-emacs@prep.ai.mit.edu'
  337.      suggesting we add it to Emacs.  If and when we do, we can change
  338.      the name easily enough.
  339.  
  340.      If one prefix is insufficient, your package may use two or three
  341.      alternative common prefixes, so long as they make sense.
  342.  
  343.      Separate the prefix from the rest of the symbol name with a hyphen,
  344.      `-'.  This will be consistent with XEmacs itself and with most
  345.      Emacs Lisp programs.
  346.  
  347.    * It is often useful to put a call to `provide' in each separate
  348.      library program, at least if there is more than one entry point to
  349.      the program.
  350.  
  351.    * If a file requires certain other library programs to be loaded
  352.      beforehand, then the comments at the beginning of the file should
  353.      say so.  Also, use `require' to make sure they are loaded.
  354.  
  355.    * If one file FOO uses a macro defined in another file BAR, FOO
  356.      should contain this expression before the first use of the macro:
  357.  
  358.           (eval-when-compile (require 'BAR))
  359.  
  360.      (And BAR should contain `(provide 'BAR)', to make the `require'
  361.      work.)  This will cause BAR to be loaded when you byte-compile
  362.      FOO.  Otherwise, you risk compiling FOO without the necessary
  363.      macro loaded, and that would produce compiled code that won't work
  364.      right.  *Note Compiling Macros::.
  365.  
  366.      Using `eval-when-compile' avoids loading BAR when the compiled
  367.      version of FOO is *used*.
  368.  
  369.    * If you define a major mode, make sure to run a hook variable using
  370.      `run-hooks', just as the existing major modes do.  *Note Hooks::.
  371.  
  372.    * If the purpose of a function is to tell you whether a certain
  373.      condition is true or false, give the function a name that ends in
  374.      `p'.  If the name is one word, add just `p'; if the name is
  375.      multiple words, add `-p'.  Examples are `framep' and
  376.      `frame-live-p'.
  377.  
  378.    * If a user option variable records a true-or-false condition, give
  379.      it a name that ends in `-flag'.
  380.  
  381.    * Please do not define `C-c LETTER' as a key in your major modes.
  382.      These sequences are reserved for users; they are the *only*
  383.      sequences reserved for users, so we cannot do without them.
  384.  
  385.      Instead, define sequences consisting of `C-c' followed by a
  386.      non-letter.  These sequences are reserved for major modes.
  387.  
  388.      Changing all the major modes in Emacs 18 so they would follow this
  389.      convention was a lot of work.  Abandoning this convention would
  390.      make that work go to waste, and inconvenience users.
  391.  
  392.    * Sequences consisting of `C-c' followed by `{', `}', `<', `>', `:'
  393.      or `;' are also reserved for major modes.
  394.  
  395.    * Sequences consisting of `C-c' followed by any other punctuation
  396.      character are allocated for minor modes.  Using them in a major
  397.      mode is not absolutely prohibited, but if you do that, the major
  398.      mode binding may be shadowed from time to time by minor modes.
  399.  
  400.    * You should not bind `C-h' following any prefix character (including
  401.      `C-c').  If you don't bind `C-h', it is automatically available as
  402.      a help character for listing the subcommands of the prefix
  403.      character.
  404.  
  405.    * You should not bind a key sequence ending in <ESC> except following
  406.      another <ESC>.  (That is, it is ok to bind a sequence ending in
  407.      `<ESC> <ESC>'.)
  408.  
  409.      The reason for this rule is that a non-prefix binding for <ESC> in
  410.      any context prevents recognition of escape sequences as function
  411.      keys in that context.
  412.  
  413.    * Applications should not bind mouse events based on button 1 with
  414.      the shift key held down.  These events include `S-mouse-1',
  415.      `M-S-mouse-1', `C-S-mouse-1', and so on.  They are reserved for
  416.      users.
  417.  
  418.    * Modes should redefine `mouse-2' as a command to follow some sort of
  419.      reference in the text of a buffer, if users usually would not want
  420.      to alter the text in that buffer by hand.  Modes such as Dired,
  421.      Info, Compilation, and Occur redefine it in this way.
  422.  
  423.    * When a package provides a modification of ordinary Emacs behavior,
  424.      it is good to include a command to enable and disable the feature,
  425.      Provide a command named `WHATEVER-mode' which turns the feature on
  426.      or off, and make it autoload (*note Autoload::.).  Design the
  427.      package so that simply loading it has no visible effect--that
  428.      should not enable the feature.  Users will request the feature by
  429.      invoking the command.
  430.  
  431.    * It is a bad idea to define aliases for the Emacs primitives.  Use
  432.      the standard names instead.
  433.  
  434.    * Redefining an Emacs primitive is an even worse idea.  It may do
  435.      the right thing for a particular program, but there is no telling
  436.      what other programs might break as a result.
  437.  
  438.    * If a file does replace any of the functions or library programs of
  439.      standard XEmacs, prominent comments at the beginning of the file
  440.      should say which functions are replaced, and how the behavior of
  441.      the replacements differs from that of the originals.
  442.  
  443.    * Please keep the names of your XEmacs Lisp source files to 13
  444.      characters or less.  This way, if the files are compiled, the
  445.      compiled files' names will be 14 characters or less, which is
  446.      short enough to fit on all kinds of Unix systems.
  447.  
  448.    * Don't use `next-line' or `previous-line' in programs; nearly
  449.      always, `forward-line' is more convenient as well as more
  450.      predictable and robust.  *Note Text Lines::.
  451.  
  452.    * Don't call functions that set the mark, unless setting the mark is
  453.      one of the intended features of your program.  The mark is a
  454.      user-level feature, so it is incorrect to change the mark except
  455.      to supply a value for the user's benefit.  *Note The Mark::.
  456.  
  457.      In particular, don't use these functions:
  458.  
  459.         * `beginning-of-buffer', `end-of-buffer'
  460.  
  461.         * `replace-string', `replace-regexp'
  462.  
  463.      If you just want to move point, or replace a certain string,
  464.      without any of the other features intended for interactive users,
  465.      you can replace these functions with one or two lines of simple
  466.      Lisp code.
  467.  
  468.    * Use lists rather than vectors, except when there is a particular
  469.      reason to use a vector.  Lisp has more facilities for manipulating
  470.      lists than for vectors, and working with lists is usually more
  471.      convenient.
  472.  
  473.      Vectors are advantageous for tables that are substantial in size
  474.      and are accessed in random order (not searched front to back),
  475.      provided there is no need to insert or delete elements (only lists
  476.      allow that).
  477.  
  478.    * The recommended way to print a message in the echo area is with
  479.      the `message' function, not `princ'.  *Note The Echo Area::.
  480.  
  481.    * When you encounter an error condition, call the function `error'
  482.      (or `signal').  The function `error' does not return.  *Note
  483.      Signaling Errors::.
  484.  
  485.      Do not use `message', `throw', `sleep-for', or `beep' to report
  486.      errors.
  487.  
  488.    * An error message should start with a capital letter but should not
  489.      end with a period.
  490.  
  491.    * Try to avoid using recursive edits.  Instead, do what the Rmail `e'
  492.      command does: use a new local keymap that contains one command
  493.      defined to switch back to the old local keymap.  Or do what the
  494.      `edit-options' command does: switch to another buffer and let the
  495.      user switch back at will.  *Note Recursive Editing::.
  496.  
  497.    * In some other systems there is a convention of choosing variable
  498.      names that begin and end with `*'.  We don't use that convention
  499.      in Emacs Lisp, so please don't use it in your programs.  (Emacs
  500.      uses such names only for program-generated buffers.)  The users
  501.      will find Emacs more coherent if all libraries use the same
  502.      conventions.
  503.  
  504.    * Indent each function with `C-M-q' (`indent-sexp') using the
  505.      default indentation parameters.
  506.  
  507.    * Don't make a habit of putting close-parentheses on lines by
  508.      themselves; Lisp programmers find this disconcerting.  Once in a
  509.      while, when there is a sequence of many consecutive
  510.      close-parentheses, it may make sense to split them in one or two
  511.      significant places.
  512.  
  513.    * Please put a copyright notice on the file if you give copies to
  514.      anyone.  Use the same lines that appear at the top of the Lisp
  515.      files in XEmacs itself.  If you have not signed papers to assign
  516.      the copyright to the Foundation, then place your name in the
  517.      copyright notice in place of the Foundation's name.
  518.  
  519. 
  520. File: lispref.info,  Node: Compilation Tips,  Next: Documentation Tips,  Prev: Style Tips,  Up: Tips
  521.  
  522. Tips for Making Compiled Code Fast
  523. ==================================
  524.  
  525.    Here are ways of improving the execution speed of byte-compiled Lisp
  526. programs.
  527.  
  528.    * Use the `profile' library to profile your program.  See the file
  529.      `profile.el' for instructions.
  530.  
  531.    * Use iteration rather than recursion whenever possible.  Function
  532.      calls are slow in XEmacs Lisp even when a compiled function is
  533.      calling another compiled function.
  534.  
  535.    * Using the primitive list-searching functions `memq', `member',
  536.      `assq', or `assoc' is even faster than explicit iteration.  It may
  537.      be worth rearranging a data structure so that one of these
  538.      primitive search functions can be used.
  539.  
  540.    * Certain built-in functions are handled specially in byte-compiled
  541.      code, avoiding the need for an ordinary function call.  It is a
  542.      good idea to use these functions rather than alternatives.  To see
  543.      whether a function is handled specially by the compiler, examine
  544.      its `byte-compile' property.  If the property is non-`nil', then
  545.      the function is handled specially.
  546.  
  547.      For example, the following input will show you that `aref' is
  548.      compiled specially (*note Array Functions::.) while `elt' is not
  549.      (*note Sequence Functions::.):
  550.  
  551.           (get 'aref 'byte-compile)
  552.                => byte-compile-two-args
  553.           
  554.           (get 'elt 'byte-compile)
  555.                => nil
  556.  
  557.    * If calling a small function accounts for a  substantial part of
  558.      your program's running time, make the function inline.  This
  559.      eliminates the function call overhead.  Since making a function
  560.      inline reduces the flexibility of changing the program, don't do
  561.      it unless it gives a noticeable speedup in something slow enough
  562.      that users care about the speed.  *Note Inline Functions::.
  563.  
  564. 
  565. File: lispref.info,  Node: Documentation Tips,  Next: Comment Tips,  Prev: Compilation Tips,  Up: Tips
  566.  
  567. Tips for Documentation Strings
  568. ==============================
  569.  
  570.    Here are some tips for the writing of documentation strings.
  571.  
  572.    * Every command, function, or variable intended for users to know
  573.      about should have a documentation string.
  574.  
  575.    * An internal variable or subroutine of a Lisp program might as well
  576.      have a documentation string.  In earlier Emacs versions, you could
  577.      save space by using a comment instead of a documentation string,
  578.      but that is no longer the case.
  579.  
  580.    * The first line of the documentation string should consist of one
  581.      or two complete sentences that stand on their own as a summary.
  582.      `M-x apropos' displays just the first line, and if it doesn't
  583.      stand on its own, the result looks bad.  In particular, start the
  584.      first line with a capital letter and end with a period.
  585.  
  586.      The documentation string can have additional lines that expand on
  587.      the details of how to use the function or variable.  The
  588.      additional lines should be made up of complete sentences also, but
  589.      they may be filled if that looks good.
  590.  
  591.    * For consistency, phrase the verb in the first sentence of a
  592.      documentation string as an infinitive with "to" omitted.  For
  593.      instance, use "Return the cons of A and B." in preference to
  594.      "Returns the cons of A and B."  Usually it looks good to do
  595.      likewise for the rest of the first paragraph.  Subsequent
  596.      paragraphs usually look better if they have proper subjects.
  597.  
  598.    * Write documentation strings in the active voice, not the passive,
  599.      and in the present tense, not the future.  For instance, use
  600.      "Return a list containing A and B." instead of "A list containing
  601.      A and B will be returned."
  602.  
  603.    * Avoid using the word "cause" (or its equivalents) unnecessarily.
  604.      Instead of, "Cause Emacs to display text in boldface," write just
  605.      "Display text in boldface."
  606.  
  607.    * Do not start or end a documentation string with whitespace.
  608.  
  609.    * Format the documentation string so that it fits in an Emacs window
  610.      on an 80-column screen.  It is a good idea for most lines to be no
  611.      wider than 60 characters.  The first line can be wider if
  612.      necessary to fit the information that ought to be there.
  613.  
  614.      However, rather than simply filling the entire documentation
  615.      string, you can make it much more readable by choosing line breaks
  616.      with care.  Use blank lines between topics if the documentation
  617.      string is long.
  618.  
  619.    * *Do not* indent subsequent lines of a documentation string so that
  620.      the text is lined up in the source code with the text of the first
  621.      line.  This looks nice in the source code, but looks bizarre when
  622.      users view the documentation.  Remember that the indentation
  623.      before the starting double-quote is not part of the string!
  624.  
  625.    * A variable's documentation string should start with `*' if the
  626.      variable is one that users would often want to set interactively.
  627.      If the value is a long list, or a function, or if the variable
  628.      would be set only in init files, then don't start the
  629.      documentation string with `*'.  *Note Defining Variables::.
  630.  
  631.    * The documentation string for a variable that is a yes-or-no flag
  632.      should start with words such as "Non-nil means...", to make it
  633.      clear that all non-`nil' values are equivalent and indicate
  634.      explicitly what `nil' and non-`nil' mean.
  635.  
  636.    * When a function's documentation string mentions the value of an
  637.      argument of the function, use the argument name in capital letters
  638.      as if it were a name for that value.  Thus, the documentation
  639.      string of the function `/' refers to its second argument as
  640.      `DIVISOR', because the actual argument name is `divisor'.
  641.  
  642.      Also use all caps for meta-syntactic variables, such as when you
  643.      show the decomposition of a list or vector into subunits, some of
  644.      which may vary.
  645.  
  646.    * When a documentation string refers to a Lisp symbol, write it as it
  647.      would be printed (which usually means in lower case), with
  648.      single-quotes around it.  For example: `lambda'.  There are two
  649.      exceptions: write t and nil without single-quotes.  (In this
  650.      manual, we normally do use single-quotes for those symbols.)
  651.  
  652.    * Don't write key sequences directly in documentation strings.
  653.      Instead, use the `\\[...]' construct to stand for them.  For
  654.      example, instead of writing `C-f', write `\\[forward-char]'.  When
  655.      Emacs displays the documentation string, it substitutes whatever
  656.      key is currently bound to `forward-char'.  (This is normally `C-f',
  657.      but it may be some other character if the user has moved key
  658.      bindings.)  *Note Keys in Documentation::.
  659.  
  660.    * In documentation strings for a major mode, you will want to refer
  661.      to the key bindings of that mode's local map, rather than global
  662.      ones.  Therefore, use the construct `\\<...>' once in the
  663.      documentation string to specify which key map to use.  Do this
  664.      before the first use of `\\[...]'.  The text inside the `\\<...>'
  665.      should be the name of the variable containing the local keymap for
  666.      the major mode.
  667.  
  668.      It is not practical to use `\\[...]' very many times, because
  669.      display of the documentation string will become slow.  So use this
  670.      to describe the most important commands in your major mode, and
  671.      then use `\\{...}' to display the rest of the mode's keymap.
  672.  
  673. 
  674. File: lispref.info,  Node: Comment Tips,  Next: Library Headers,  Prev: Documentation Tips,  Up: Tips
  675.  
  676. Tips on Writing Comments
  677. ========================
  678.  
  679.    We recommend these conventions for where to put comments and how to
  680. indent them:
  681.  
  682. `;'
  683.      Comments that start with a single semicolon, `;', should all be
  684.      aligned to the same column on the right of the source code.  Such
  685.      comments usually explain how the code on the same line does its
  686.      job.  In Lisp mode and related modes, the `M-;'
  687.      (`indent-for-comment') command automatically inserts such a `;' in
  688.      the right place, or aligns such a comment if it is already present.
  689.  
  690.      This and following examples are taken from the Emacs sources.
  691.  
  692.           (setq base-version-list                 ; there was a base
  693.                 (assoc (substring fn 0 start-vn)  ; version to which
  694.                        file-version-assoc-list))  ; this looks like
  695.                                                   ; a subversion
  696.  
  697. `;;'
  698.      Comments that start with two semicolons, `;;', should be aligned to
  699.      the same level of indentation as the code.  Such comments usually
  700.      describe the purpose of the following lines or the state of the
  701.      program at that point.  For example:
  702.  
  703.           (prog1 (setq auto-fill-function
  704.                        ...
  705.                        ...
  706.             ;; update modeline
  707.             (redraw-modeline)))
  708.  
  709.      Every function that has no documentation string (because it is use
  710.      only internally within the package it belongs to), should have
  711.      instead a two-semicolon comment right before the function,
  712.      explaining what the function does and how to call it properly.
  713.      Explain precisely what each argument means and how the function
  714.      interprets its possible values.
  715.  
  716. `;;;'
  717.      Comments that start with three semicolons, `;;;', should start at
  718.      the left margin.  Such comments are used outside function
  719.      definitions to make general statements explaining the design
  720.      principles of the program.  For example:
  721.  
  722.           ;;; This Lisp code is run in XEmacs
  723.           ;;; when it is to operate as a server
  724.           ;;; for other processes.
  725.  
  726.      Another use for triple-semicolon comments is for commenting out
  727.      lines within a function.  We use triple-semicolons for this
  728.      precisely so that they remain at the left margin.
  729.  
  730.           (defun foo (a)
  731.           ;;; This is no longer necessary.
  732.           ;;;  (force-mode-line-update)
  733.             (message "Finished with %s" a))
  734.  
  735. `;;;;'
  736.      Comments that start with four semicolons, `;;;;', should be aligned
  737.      to the left margin and are used for headings of major sections of a
  738.      program.  For example:
  739.  
  740.           ;;;; The kill ring
  741.  
  742. The indentation commands of the Lisp modes in XEmacs, such as `M-;'
  743. (`indent-for-comment') and <TAB> (`lisp-indent-line') automatically
  744. indent comments according to these conventions, depending on the number
  745. of semicolons.  *Note Manipulating Comments: (emacs)Comments.
  746.  
  747. 
  748. File: lispref.info,  Node: Library Headers,  Prev: Comment Tips,  Up: Tips
  749.  
  750. Conventional Headers for XEmacs Libraries
  751. =========================================
  752.  
  753.    XEmacs has conventions for using special comments in Lisp libraries
  754. to divide them into sections and give information such as who wrote
  755. them.  This section explains these conventions.  First, an example:
  756.  
  757.      ;;; lisp-mnt.el --- minor mode for Emacs Lisp maintainers
  758.      
  759.      ;; Copyright (C) 1992 Free Software Foundation, Inc.
  760.      
  761.      ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
  762.      ;; Maintainer: Eric S. Raymond <esr@snark.thyrsus.com>
  763.      ;; Created: 14 Jul 1992
  764.      ;; Version: 1.2
  765.      ;; Keywords: docs
  766.      
  767.      ;; This file is part of XEmacs.
  768.      COPYING PERMISSIONS...
  769.  
  770.    The very first line should have this format:
  771.  
  772.      ;;; FILENAME --- DESCRIPTION
  773.  
  774. The description should be complete in one line.
  775.  
  776.    After the copyright notice come several "header comment" lines, each
  777. beginning with `;; HEADER-NAME:'.  Here is a table of the conventional
  778. possibilities for HEADER-NAME:
  779.  
  780. `Author'
  781.      This line states the name and net address of at least the principal
  782.      author of the library.
  783.  
  784.      If there are multiple authors, you can list them on continuation
  785.      lines led by `;;' and a tab character, like this:
  786.  
  787.           ;; Author: Ashwin Ram <Ram-Ashwin@cs.yale.edu>
  788.           ;;      Dave Sill <de5@ornl.gov>
  789.           ;;      Dave Brennan <brennan@hal.com>
  790.           ;;      Eric Raymond <esr@snark.thyrsus.com>
  791.  
  792. `Maintainer'
  793.      This line should contain a single name/address as in the Author
  794.      line, or an address only, or the string `FSF'.  If there is no
  795.      maintainer line, the person(s) in the Author field are presumed to
  796.      be the maintainers.  The example above is mildly bogus because the
  797.      maintainer line is redundant.
  798.  
  799.      The idea behind the `Author' and `Maintainer' lines is to make
  800.      possible a Lisp function to "send mail to the maintainer" without
  801.      having to mine the name out by hand.
  802.  
  803.      Be sure to surround the network address with `<...>' if you
  804.      include the person's full name as well as the network address.
  805.  
  806. `Created'
  807.      This optional line gives the original creation date of the file.
  808.      For historical interest only.
  809.  
  810. `Version'
  811.      If you wish to record version numbers for the individual Lisp
  812.      program, put them in this line.
  813.  
  814. `Adapted-By'
  815.      In this header line, place the name of the person who adapted the
  816.      library for installation (to make it fit the style conventions, for
  817.      example).
  818.  
  819. `Keywords'
  820.      This line lists keywords for the `finder-by-keyword' help command.
  821.      This field is important; it's how people will find your package
  822.      when they're looking for things by topic area.  To separate the
  823.      keywords, you can use spaces, commas, or both.
  824.  
  825.    Just about every Lisp library ought to have the `Author' and
  826. `Keywords' header comment lines.  Use the others if they are
  827. appropriate.  You can also put in header lines with other header
  828. names--they have no standard meanings, so they can't do any harm.
  829.  
  830.    We use additional stylized comments to subdivide the contents of the
  831. library file.  Here is a table of them:
  832.  
  833. `;;; Commentary:'
  834.      This begins introductory comments that explain how the library
  835.      works.  It should come right after the copying permissions.
  836.  
  837. `;;; Change log:'
  838.      This begins change log information stored in the library file (if
  839.      you store the change history there).  For most of the Lisp files
  840.      distributed with XEmacs, the change history is kept in the file
  841.      `ChangeLog' and not in the source file at all; these files do not
  842.      have a `;;; Change log:' line.
  843.  
  844. `;;; Code:'
  845.      This begins the actual code of the program.
  846.  
  847. `;;; FILENAME ends here'
  848.      This is the "footer line"; it appears at the very end of the file.
  849.      Its purpose is to enable people to detect truncated versions of
  850.      the file from the lack of a footer line.
  851.  
  852. 
  853. File: lispref.info,  Node: Building XEmacs and Object Allocation,  Next: Standard Errors,  Prev: Tips,  Up: Top
  854.  
  855. Building XEmacs; Allocation of Objects
  856. **************************************
  857.  
  858.    This chapter describes how the runnable XEmacs executable is dumped
  859. with the preloaded Lisp libraries in it and how storage is allocated.
  860.  
  861.    There is an entire separate document, the `XEmacs Internals Manual',
  862. devoted to the internals of XEmacs from the perspective of the C
  863. programmer.  It contains much more detailed information about the build
  864. process, the allocation and garbage-collection process, and other
  865. aspects related to the internals of XEmacs.
  866.  
  867. * Menu:
  868.  
  869. * Building XEmacs::     How to preload Lisp libraries into XEmacs.
  870. * Pure Storage::        A kludge to make preloaded Lisp functions sharable.
  871. * Garbage Collection::  Reclaiming space for Lisp objects no longer used.
  872.  
  873. 
  874. File: lispref.info,  Node: Building XEmacs,  Next: Pure Storage,  Up: Building XEmacs and Object Allocation
  875.  
  876. Building XEmacs
  877. ===============
  878.  
  879.    This section explains the steps involved in building the XEmacs
  880. executable.  You don't have to know this material to build and install
  881. XEmacs, since the makefiles do all these things automatically.  This
  882. information is pertinent to XEmacs maintenance.
  883.  
  884.    The `XEmacs Internals Manual' contains more information about this.
  885.  
  886.    Compilation of the C source files in the `src' directory produces an
  887. executable file called `temacs', also called a "bare impure XEmacs".
  888. It contains the XEmacs Lisp interpreter and I/O routines, but not the
  889. editing commands.
  890.  
  891.    Before XEmacs is actually usable, a number of Lisp files need to be
  892. loaded.  These define all the editing commands, plus most of the startup
  893. code and many very basic Lisp primitives.  This is accomplished by
  894. loading the file `loadup.el', which in turn loads all of the other
  895. standardly-loaded Lisp files.
  896.  
  897.    It takes a substantial time to load the standard Lisp files.
  898. Luckily, you don't have to do this each time you run XEmacs; `temacs'
  899. can dump out an executable program called `xemacs' that has these files
  900. preloaded.  `xemacs' starts more quickly because it does not need to
  901. load the files.  This is the XEmacs executable that is normally
  902. installed.
  903.  
  904.    To create `xemacs', use the command `temacs -batch -l loadup dump'.
  905. The purpose of `-batch' here is to tell `temacs' to run in
  906. non-interactive, command-line mode. (`temacs' can *only* run in this
  907. fashion.  Part of the code required to initialize frames and faces is
  908. in Lisp, and must be loaded before XEmacs is able to create any frames.)
  909. The argument `dump' tells `loadup.el' to dump a new executable named
  910. `xemacs'.
  911.  
  912.    The dumping process is highly system-specific, and some operating
  913. systems don't support dumping.  On those systems, you must start XEmacs
  914. with the `temacs -batch -l loadup run-temacs' command each time you use
  915. it.  This takes a substantial time, but since you need to start Emacs
  916. once a day at most--or once a week if you never log out--the extra time
  917. is not too severe a problem. (In older versions of Emacs, you started
  918. Emacs from `temacs' using `temacs -l loadup'.)
  919.  
  920.    You are free to start XEmacs directly from `temacs' if you want,
  921. even if there is already a dumped `xemacs'.  Normally you wouldn't want
  922. to do that; but the Makefiles do this when you rebuild XEmacs using
  923. `make all-elc', which builds XEmacs and simultaneously compiles any
  924. out-of-date Lisp files. (You need `xemacs' in order to compile Lisp
  925. files.  However, you also need the compiled Lisp files in order to dump
  926. out `xemacs'.  If both of these are missing or corrupted, you are out
  927. of luck unless you're able to bootstrap `xemacs' from `temacs'.  Note
  928. that `make all-elc' actually loads the alternative loadup file
  929. `loadup-el.el', which works like `loadup.el' but disables the
  930. pure-copying process and forces XEmacs to ignore any compiled Lisp
  931. files even if they exist.)
  932.  
  933.    You can specify additional files to preload by writing a library
  934. named `site-load.el' that loads them.  You may need to increase the
  935. value of `PURESIZE', in `src/puresize.h', to make room for the
  936. additional files.  You should *not* modify this file directly, however;
  937. instead, use the `--puresize' configuration option. (If you run out of
  938. pure space while dumping `xemacs', you will be told how much pure space
  939. you actually will need.) However, the advantage of preloading
  940. additional files decreases as machines get faster.  On modern machines,
  941. it is often not advisable, especially if the Lisp code is on a file
  942. system local to the machine running XEmacs.
  943.  
  944.    You can specify other Lisp expressions to execute just before dumping
  945. by putting them in a library named `site-init.el'.  However, if they
  946. might alter the behavior that users expect from an ordinary unmodified
  947. XEmacs, it is better to put them in `default.el', so that users can
  948. override them if they wish.  *Note Start-up Summary::.
  949.  
  950.    Before `loadup.el' dumps the new executable, it finds the
  951. documentation strings for primitive and preloaded functions (and
  952. variables) in the file where they are stored, by calling
  953. `Snarf-documentation' (*note Accessing Documentation::.).  These
  954. strings were moved out of the `xemacs' executable to make it smaller.
  955. *Note Documentation Basics::.
  956.  
  957.  - Function: dump-emacs TO-FILE FROM-FILE
  958.      This function dumps the current state of XEmacs into an executable
  959.      file TO-FILE.  It takes symbols from FROM-FILE (this is normally
  960.      the executable file `temacs').
  961.  
  962.      If you use this function in an XEmacs that was already dumped, you
  963.      must set `command-line-processed' to `nil' first for good results.
  964.      *Note Command Line Arguments::.
  965.  
  966.  - Function: run-emacs-from-temacs &rest ARGS
  967.      This is the function that implements the `run-temacs' command-line
  968.      argument.  It is called from `loadup.el' as appropriate.  You
  969.      should most emphatically *not* call this yourself; it will
  970.      reinitialize your XEmacs process and you'll be sorry.
  971.  
  972.  - Command: emacs-version
  973.      This function returns a string describing the version of XEmacs
  974.      that is running.  It is useful to include this string in bug
  975.      reports.
  976.  
  977.           (emacs-version)
  978.             => "XEmacs 20.1 [Lucid] (i586-unknown-linux2.0.29)
  979.                            of Mon Apr  7 1997 on altair.xemacs.org"
  980.  
  981.      Called interactively, the function prints the same information in
  982.      the echo area.
  983.  
  984.  - Variable: emacs-build-time
  985.      The value of this variable is the time at which XEmacs was built
  986.      at the local site.
  987.  
  988.           emacs-build-time "Mon Apr  7 20:28:52 1997"
  989.                =>
  990.  
  991.  - Variable: emacs-version
  992.      The value of this variable is the version of Emacs being run.  It
  993.      is a string, e.g. `"20.1 XEmacs Lucid"'.
  994.  
  995.    The following two variables did not exist before FSF GNU Emacs
  996. version 19.23 and XEmacs version 19.10, which reduces their usefulness
  997. at present, but we hope they will be convenient in the future.
  998.  
  999.  - Variable: emacs-major-version
  1000.      The major version number of Emacs, as an integer.  For XEmacs
  1001.      version 20.1, the value is 20.
  1002.  
  1003.  - Variable: emacs-minor-version
  1004.      The minor version number of Emacs, as an integer.  For XEmacs
  1005.      version 20.1, the value is 1.
  1006.  
  1007. 
  1008. File: lispref.info,  Node: Pure Storage,  Next: Garbage Collection,  Prev: Building XEmacs,  Up: Building XEmacs and Object Allocation
  1009.  
  1010. Pure Storage
  1011. ============
  1012.  
  1013.    XEmacs Lisp uses two kinds of storage for user-created Lisp objects:
  1014. "normal storage" and "pure storage".  Normal storage is where all the
  1015. new data created during an XEmacs session is kept; see the following
  1016. section for information on normal storage.  Pure storage is used for
  1017. certain data in the preloaded standard Lisp files--data that should
  1018. never change during actual use of XEmacs.
  1019.  
  1020.    Pure storage is allocated only while `temacs' is loading the
  1021. standard preloaded Lisp libraries.  In the file `xemacs', it is marked
  1022. as read-only (on operating systems that permit this), so that the
  1023. memory space can be shared by all the XEmacs jobs running on the machine
  1024. at once.  Pure storage is not expandable; a fixed amount is allocated
  1025. when XEmacs is compiled, and if that is not sufficient for the preloaded
  1026. libraries, `temacs' aborts with an error message.  If that happens, you
  1027. must increase the compilation parameter `PURESIZE' using the
  1028. `--puresize' option to `configure'.  This normally won't happen unless
  1029. you try to preload additional libraries or add features to the standard
  1030. ones.
  1031.  
  1032.  - Function: purecopy OBJECT
  1033.      This function makes a copy of OBJECT in pure storage and returns
  1034.      it.  It copies strings by simply making a new string with the same
  1035.      characters in pure storage.  It recursively copies the contents of
  1036.      vectors and cons cells.  It does not make copies of other objects
  1037.      such as symbols, but just returns them unchanged.  It signals an
  1038.      error if asked to copy markers.
  1039.  
  1040.      This function is a no-op except while XEmacs is being built and
  1041.      dumped; it is usually called only in the file
  1042.      `xemacs/lisp/prim/loaddefs.el', but a few packages call it just in
  1043.      case you decide to preload them.
  1044.  
  1045.  - Variable: pure-bytes-used
  1046.      The value of this variable is the number of bytes of pure storage
  1047.      allocated so far.  Typically, in a dumped XEmacs, this number is
  1048.      very close to the total amount of pure storage available--if it
  1049.      were not, we would preallocate less.
  1050.  
  1051.  - Variable: purify-flag
  1052.      This variable determines whether `defun' should make a copy of the
  1053.      function definition in pure storage.  If it is non-`nil', then the
  1054.      function definition is copied into pure storage.
  1055.  
  1056.      This flag is `t' while loading all of the basic functions for
  1057.      building XEmacs initially (allowing those functions to be sharable
  1058.      and non-collectible).  Dumping XEmacs as an executable always
  1059.      writes `nil' in this variable, regardless of the value it actually
  1060.      has before and after dumping.
  1061.  
  1062.      You should not change this flag in a running XEmacs.
  1063.  
  1064.